

<!DOCTYPE html>
<html>

<head>


<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<!--360浏览器优先以webkit内核解析-->


<title>TI新增费用申请</title>

<link rel="shortcut icon" href="__STATIC__/layout/favicon.ico">
<link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link href="__STATIC__/layout/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
<link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
<link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
<link href="__STATIC__/layout/css/channel.css?v=4.1.0" rel="stylesheet">
<!-- Sweet Alert -->
<link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <script src="__STATIC__/layout/js/jquery.min.js"></script>
    <script src="__STATIC__/xds/js/select.js"></script>
    <script src="__STATIC__/xds/js/time.js"></script>
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">


    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/plugins/webuploader/webuploader.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/demo/webuploader-demo.css">

    <style>
        .handup{
            color: #a6e1fc;
            display: inline-block;
            padding-left: 10px;
            cursor: pointer;
        }
       .btn-white.active{
            color: #fff;
            background-color: #337ab7;
        }
    </style>

</head>

<body class="white-bg" style="padding: 3px;font-size: 13px">
    <div class="page-heade">
       <h2 class="title_color text-center">TI费用申请</h2>
    </div>
    <form action="" class="form-inline"   id="addInfo">
        <table class="table table-bordered bud_hei"  style="margin-bottom: 10px">
            <tr>
                <td style="" class="text-center">活动主题：</td>
                <td colspan="3">
                    <div class="form-group">
                     <input type="text" name="title" ret="活动主题不能为空" {if condition="$aid neq 0"} value="{$apply['title']}" {/if} class="form-control" placeholder="请输入活动主题" id="actionTheme">
                    </div>
                </td>
                <td style="" class="text-center">活动经销商：</td>
                <td colspan="3" id="jxs_id" >

                    {if condition="$aid neq 0"} {$apply['jxs']} {/if}
                </td>
                <!--<script>
                    $(function () {
                        entranceX('jxs_id',
                            "{:url('select/myjxsjson')}",
                            '{:url("BiHaiChaoSheng/selectList?str=jxs_id&url=myzonetreeajax")}',
                            '经销商不能为空', '');
                    });
                </script>-->
                {if condition="$aid eq 0"}
                <script>
                    $(function () {
                        entranceX('jxs_id',
                            "{:url('select/myjxsjson')}",
                            '{:url("BiHaiChaoSheng/selectList?str=jxs_id&url=myzonetreeajax")}',
                            '经销商不能为空', '');
                    });
                </script>
                {/if}
            </tr>
            <tr >
                <td class="text-center">是否新进货&nbsp;
                    <span class="fa fa-question-circle" data-toggle="tooltip" data-placement="right" title="Tooltip on left">

                    </span>
                </td>
                <td  id="jinhuodeal">
                    <div id="us" class="btn-group">
                    </div>
                    <script>
                        /*进货or不进货*/

                            $('#us').AddRadioX(
                                [
                                    {
                                        title:'进货',
                                        name:'is_jinhuo',
                                        className:'jinghuo',
                                        isTrue:false,
                                        value:1,
                                        fun:function (obj) {
                                            $(obj).click(function(){
                                                $(this).parents('td').siblings().find('input[type2="text"]').attr('disabled',false);
                                                $(this).parent('label').siblings().removeClass('active');
                                                $(this).parent('label').addClass('active');
                                            });
                                        }
                                    },
                                    {
                                        title:'不进货',
                                        name:'is_jinhuo',
                                        className:'bujinghuo',
                                        isTrue:true,
                                        value:0,
                                        fun:function (obj) {
                                            $(obj).click(function(){
                                                $(this).parents('td').siblings().find('input[type2="text"]').attr('disabled',true);
                                                $(this).parent('label').siblings().removeClass('active');
                                                $(this).parent('label').addClass('active');
                                            })

                                        }
                                    }

                               ]
                            );


                    </script>
                </td>
                <td style="width: 80px" class="text-right">进货时段</td>
                {if condition="$apply['is_jinhuo'] eq 1"}
                <td class="xds_addTime"  whereTime="startName:jinhuo_shijian_start,endName:jinhuo_shijian_end,startvalue:{$apply['jinhuo_shijian_start']},endvalue:{$apply['jinhuo_shijian_end']}">
                </td>
                {else/}
                <td class="xds_addTime" wheretime="startName:jinhuo_shijian_start,endName:jinhuo_shijian_end">
                    <input type="text" class="form-control" id="xds_addTime0" type2="text" style="width: 220px" placeholder="开始时间 至 结束时间" lay-key="1">
                    <!--<input name="jinhuo_shijian_start" type="hidden" value="2018-9-12">
                    <input name="jinhuo_shijian_end" type="hidden" value="2018-10-24">-->
                </td>
                {/if}
                {if condition="$apply['is_jinhuo'] eq 1"}
                <script>
                    $(".xds_addTime").find('input[name=jinhuo_shijian_start]').val("$apply['jinhuo_shijian_start']")
                    $(".xds_addTime").find('input[name=jinhuo_shijian_end]').val("$apply['jinhuo_shijian_end']")
                    console.log('eeeeee');
                    /*$(function () {
                        entranceX('jxs_id',
                            "{:url('select/myjxsjson')}",
                            '{:url("BiHaiChaoSheng/selectList?str=jxs_id&url=myzonetreeajax")}',
                            '经销商不能为空', '');
                    });*/
                </script>
                {/if}
                <td style="" class="text-center">承诺进货额：</td>
                <td>
                    <div class="input-group">
                        <input type="text" class="form-control jinhuojine" type2="text"  onblur="money_to();" ret="承诺进货额不能为空" name="jinhuo_jine" id="jinhuo_jine" aria-label="RMB"
                               style="width: 60px;height: 30px" disabled="true">
                        <span class="input-group-addon">元</span>
                    </div>
                    <script>
                        function money_to(){
                            if($('#jinhuo_jine').val()>0){
                                var jinhuo_jine = $('#jinhuo_jine').val();
                                var hanshuis = $('#hanshuis').text();
                                var yjjhfb =parseFloat(100*hanshuis/jinhuo_jine);
                                $('#yjjhfb').val(yjjhfb);
                            }else{
                                alert('承诺进货额必须为正数');
                                $('#jinhuo_jine').val("");
                            }
                        }
                    </script>
                </td>
                <td class="text-center">预计进货费比&nbsp;<span class="fa fa-question-circle" data-toggle="tooltip" data-placement="left" title="注：预计进货费比=总预计费用额/承诺进货额"></span>
                </td>
                <td>
                    <div class="input-group">
                        <input type="text" class="form-control" aria-label="" style="width: 60px;height: 30px" id="yjjhfb"
                               disabled="true">
                        <span class="input-group-addon">%</span>
                    </div>
                </td>
            </tr>


                    </td>
                </tr>
        </table>
        <p class="text-right">金额单位：元</p>
        <div>
            <a href="javascript:;" class="btn btn-info" id="addfreeMIngxi" aid="{$aid}" onclick="ifInputNullGto();"><span class="fa fa-plus-circle"></span>&nbsp;添加费用明细</a>&nbsp;&nbsp;
            <a href="javascript:;" class="btn btn-success" id="jbxx" onclick="jiben()" style="color: #fff;">基本信息</a>
            <a href="javascript:;" class="btn btn-success" id="xxxx" onclick="xiangxi()" style="color: #fff;">详细信息</a>
            {if condition="$hbnum neq 0"}
            <a href="javascript:;" class="btn btn-success" id="hbxx" onclick="huobu()" style="color: #fff;">货补信息</a>
            {/if}
        </div>
    </form>
        <table class="table table-bordered table-striped jiben">
            <thead>
                <tr class="info">
                    <th class="text-center">操作</th>
                    <th class="text-center">活动期间</th>
                    <th class="text-center">活动描述</th>
                    <th class="text-center">活动产品</th>
                    <th class="text-center">活动系统名/网点数</th>
                    <th class="text-center">费用类型</th>
                    <th class="text-center">费用额</th>
                    <th class="text-center">支付方式</th>
                    <th class="text-center">费用说明</th>
                    <th class="text-center">不做活动销量</th>
                    <th class="text-center">做活动销量</th>
                    <th class="text-center">费用率</th>
                    <th class="text-center">ROI</th>
                </tr>
            </thead>
            <tbody>
            {if condition="$aid neq 0"}
            {volist name="applyde" id="vo"}
                <tr>
                   <td class="text-center" rowspan="{$vo['feenum']}" colspan="1">
                       <input type="button" class="btn btn-info btn-sm ckde" value="修改" onclick="xiugai({$vo.id},{$vo.ctime})"/>
                       <input type="button" class="btn btn-danger btn-sm" value="删除本条" onclick="shanchu({$vo.id},{$vo.ctime})"/>
                     <!--<button class="btn btn-info btn-circle btn-sm" type="button" title="修改"><i class="fa fa-pencil-square-o"></i></button><br>
                     <button class="btn btn-warning btn-circle btn-sm" type="button" title="删除"><i class="fa fa-times"></i></button>-->
                   </td>
                   <td rowspan="{$vo['feenum']}" colspan="1">
                    <p>{$vo['start']}</p>
                    <p>{$vo['end']}</p>
                    <p>共{$vo['daynum']}天</p>
                  </td>
                   <td rowspan="{$vo['feenum']}" colspan="1">{$vo['brief']}</td>
                   <td rowspan="{$vo['feenum']}" colspan="1">
                       {volist name="vo['cp_name']" id="vo2"}
                        <p>{$vo2}</p>
                       {/volist}
                        <p class="spanTotal">共<span>{$vo['cp_num']}</span>个 {$vo['cp_type']}</p>
                   </td>
                   <td rowspan="{$vo['feenum']}" colspan="1">
                       {$vo['kh']}

                   </td>
                    {volist name="vo['fee']" id="vo3" key="k"}
                    {if $k==1}
                    <td>{$vo3['title']} </td>
                    <td class="text-right">{$vo3['hanshuis']}</td>
                    <td>{$vo3['payname']}</td>
                    <td>{$vo3['feiyongmiaoshu']}</td>
                    {/if}
                    {/volist}



                    <td  rowspan="{$vo['feenum']}" colspan="1" class="text-right">{$vo['noSales']}</td>
                    <td  rowspan="{$vo['feenum']}" colspan="1" class="text-right">{$vo['yesSales']}</td>
                    <td  rowspan="{$vo['feenum']}" colspan="1" class="text-right">{$vo['feiyonglv']}%</td>
                    <td  rowspan="{$vo['feenum']}" colspan="1" class="text-right">{$vo['roi']}%</td>
                </tr>
         <!-- 下面是什么，我忘记了 -->
            {volist name="vo['fee']" id="vo3" key="k"}
            {if $k!=1}
            <td>{$vo3['title']} </td>
            <td class="text-right">{$vo3['hanshuis']}</td>
            <td>{$vo3['payname']}</td>
            <td>{$vo3['feiyongmiaoshu']}</td>
            {/if}
            {/volist}

            {/volist}
            {/if}
            </tbody>
            <tfoot>
                <tr class="trTotal text-right">
                    <td colspan="5">合计</td>
                    <td></td>
                    <td id="hanshuis">{$all['hanshuis']}</td>
                    <td></td>
                    <td></td>
                    <td>{$all['noSales']}</td>
                    <td>{$all['yesSales']}</td>
                    <td>{$all['feiyonglv']}</td>
                    <td>0.00%</td>
                </tr>
            </tfoot>
        </table>

    <table class="table table-bordered table-striped xiangxi" id="" style="display: none;white-space: nowrap;">
        <thead>
        <tr class="info">
            <th class="text-center">状态</th>
            <th class="text-center">明细编号</th>
            <th class="text-center">经销商名称</th>
            <th class="text-center">活动执行时间</th>
            <th class="text-center">预计核销时间</th>
            <th class="text-center">产品类型</th>
            <th class="text-center">产品名称</th>
            <th class="text-center">三级费用科目</th>
            <th class="text-center">支付方式</th>
            <th class="text-center">未税金额</th>
            <th class="text-center">是否增值税（可抵扣）</th>
            <th class="text-center">税率</th>
            <th class="text-center">含税金额</th>

            <th class="text-center">实际投入费用</th>
            <th class="text-center">已核销费用</th>
            <th class="text-center">费用说明</th>
            <th class="text-center">做活动销量</th>
            <th class="text-center">预计费用率</th>
            <th class="text-center">实际销量</th>
            <th class="text-center">ROI</th>
            <th class="text-center">活动简述</th>
            <th class="text-center">成本中心</th>
            <th class="text-center">陈列类型</th>
            <th class="text-center">陈列位置</th>
            <th class="text-center">陈列尺寸</th>
            <th class="text-center">收款方</th>
        </tr>
        </thead>
        <tbody>
            {if condition="$aid neq 0"}
            {volist name="xxxx" id="vot"}
            <tr>
            <td class="text-center">
                <p>正常</p>
            </td>
            <td  class="text-right">
                <p>{$vot['sn']}</p>
            </td>
            <td  class="text-right">{$vot['title']}</td>
            <td  class="text-right">
                <p>{$vot['zxtime']}</p>
            </td>
            <td  class="text-right">
                <p>{$vot['expCanTime']}</p>
            </td>
            <td  class="text-right">{$vot['cp_type']}</td>
            <td class="text-right">{$vot['cp_name']}</td>
            <td>{$vot['feetype']}</td>
            <td class="text-right">{$vot['paymethod']}</td>
            <td class="text-right"> {$vot['amount']}</td>
            <td class="text-right">是</td>
            <td class="text-right"> {$vot['shuilv']}%</td>
            <td class="text-right">{$vot['hanshui']}</td>
            <td class="text-right">{$vot['yjsjtrfy']}</td>
            <td class="text-right">{$vot['hx_yihexiao2']}</td>
            <td class="text-right">{$vot['feiyongmiaoshu']}</td>
            <td class="text-right">{$vot['hdxl']}</td>
            <td class="text-right">{$vot['yjfyl']}</td>
            <td class="text-right">{$vot['shijixiaoliang']}</td> <!--实际销量-->
            <td class="text-right">{$vot['yujiroi']}%</td>
            <td class="text-right">{$vot['brief']}</td>
            <td class="text-right">{$vot['cb_name']}</td>
            <td class="text-right">{$vot['cl_type']}</td>
            <td class="text-right">{$vot['cl_place']}</td>
            <td class="text-right">{$vot['cl_size']}</td>
            <td class="text-right">{$vot['payeetype']}:{$vot['payee']}</td>





            </tr>
            {/volist}
            {/if}

        </tbody>
        <tfoot>
        <!--<tr class="trTotal text-right">
            <td colspan="5">合计2222</td>
            <td></td>
            <td>23213.00</td>
            <td></td>
            <td></td>
            <td>12.00</td>
            <td>11.00</td>
            <td>211027.27%</td>
            <td>0.00%</td>
        </tr>-->
        </tfoot>
    </table>



    <table class="table table-bordered table-striped huobu" id="" style="display: none">
        <thead>
        <tr class="info">
            <th class="text-center">申领类型</th>
            <th class="text-center">物料名称</th>
            <th class="text-center">物料类型</th>
            <th class="text-center">规格</th>
            <th class="text-center">单位</th>
            <th class="text-center">单价</th>
            <th class="text-center">数量</th>
            <th class="text-center">金额</th>

            <!--<th class="text-center">支付方式</th>
            <th class="text-center">未税金额</th>
            <th class="text-center">是否增值税（可抵扣）</th>
            <th class="text-center">税率</th>
            <th class="text-center">含税金额</th>-->
        </tr>
        </thead>
        <tbody>

        {if condition="$hbnum neq 0"}
        {volist name="hbxx" id="hot"}
        <script>
            console.log(ee);
        </script>
        <tr>
            <td class="text-center ">

                <p>货补</p>
            </td>
            <td>
                <p>{$hot['wlName']}</p>
            </td>
            <td>{$hot['wltype']}</td>
            <td>
                <p>{$hot['gg']}</p>
            </td>
            <td>
                <p>{$hot['unit']}</p>
            </td>
            <td>{$hot['factory']}</td>
            <td class="text-right">{$hot['num']}</td>
            <td>{$hot['money']}</td>
            <!--<td>{$vot['paymethod']}</td>
            <td class="text-right">12.00</td>
            <td class="text-right">11.00</td>
            <td class="text-right">211027.27%</td>
            <td class="text-right">-0.00%</td>-->
        </tr>
        {/volist}
        {/if}

        </tbody>
        <tfoot>
        <tr class="trTotal text-right">
            <td colspan="5">合计</td>
            <td></td>
            <td>23213.00</td>
            <td>2</td>
            <!--<td></td>
            <td>12.00</td>
            <td>11.00</td>
            <td>211027.27%</td>
            <td>0.00%</td>-->
        </tr>
        </tfoot>
    </table>

         <div class="alert alert-warning" id="applyresult" style="margin-bottom: 4px;">
             {if condition="$aid neq 0"}
             本申请中：{volist name="feeda" id="fe"}{$fe['title']}:{$fe['hanshuis']}元;{/volist}总费用：{$all['hanshuis']}元。总预计销量：{$all['yesSales']}元；总费用率：{$all['feiyonglv']}；总ROI：0%；
             {/if}
             <!--本申请中：样酒：23213.00元；总费用：23213.00元。总预计销量：11.00元；总费用率：211027.27%；总ROI：0%；-->
        </div>
        <div class="alert alert-warning">
          费用申请说明：1、如未达到当月承诺未税进货金额，则促销费用按实际未税进货金额比例相应减少
        </div>
      <!--<div class="alert alert-success">
        <button class="btn btn-primary">上传附件</button>&nbsp;
        <a href="javascript:;" class="btn btn-white">附件说明&nbsp;&nbsp;<span class="fa fa-question-circle" data-toggle="tooltip" data-placement="right" title="Tooltip on left"></span></a>
      </div>-->

    <div class="form-group white-bg alert alert-success" style="margin:20px 10px 20px 20px;">
        <div id="uploader" class="wu-example">
            <!--用来存放文件信息-->
            <div id="thelist" class="uploader-list">
                {volist name="fujian" id="fo"}
                <h4>{$fo.file_name}</h4>
                {/volist}
            </div>
            <div class="btns">
                <div id="picker">选择文件</div>
                <button id="ctlBtn" class="btn btn-sm btn-default">开始上传</button>
            </div>
            <input type="hidden" name="attach" id="attach" {if condition="$aid neq 0"} value="{$apply.annex_id}" {/if} >
        </div>
        <span>注：最多上传15个文件，每个文件小于50M,支持格式：</span><br>jpg,bnp,gif,png,jpeg,tif,raw,doc,docx,xls,xlsx,ppt,pptx,txt,pdf,rar,zip,mp4,avi,rmvb,rm,mid,3gp,AVI,3GP,,mpg,mp3,wma,wav
    </div>




      <div class="row-margin-top text-center">
          <input type="button" class="btn btn-primary" onclick="tijiao(1)" value="保存为草稿"/>
          <input type="button" class="btn btn-warning" onclick="tijiao(3)" value="保存并提交流程"/>
          <!--<input type="button" class="btn btn-warning" value="返回" id="fanhui">-->


        <!--<input type="button" name="" id="savecg" value="保存草稿" class="btn btn-info">&nbsp;&nbsp;
        <input type="button" name="" id="savetj" value="保存并提交流程" class="btn btn-success">&nbsp;&nbsp;-->
        <input type="button" name="" id="toback" value="返回" class="btn btn-warning" >
      </div>
    <div class="modal fade myModel1" tabindex="-1" role="dialog"  id="myModel1">
        <form action="" class="form-inline"   id="addInfo2">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">请选择费用类型</h4>
                </div>
                <div class="modal-body">
                    <input name="fylx" id="fylx" value="0" type="hidden"/>
                    <div class="form-group" style="padding: 10px;display: inline-block;">
                        <input type="checkbox" name="formalhbl"  id="formalhbl" data-id="1" onclick="feedeal(1)"/>&nbsp;&nbsp;
                        <label for="formalhbl">常规后补类</label>
                    </div>
                    <div class="form-group" style="padding: 10px;display: inline-block;">
                        <input type="checkbox" name="suihuozhekou"  id="suihuozhekou" data-id="1" onclick="feedeal(2)"/>&nbsp;&nbsp;
                        <label for="suihuozhekou">随货折扣类</label>
                    </div>
                    <div class="form-group" style="padding: 10px;display: inline-block;">
                        <input type="checkbox"  name="tejiabucha"  id="tejiabucha" data-id="1" onclick="feedeal(4)"/>&nbsp;&nbsp;
                        <label for="tejiabucha">特价补差类</label>
                    </div>
                    <div class="form-group" style="padding: 10px;display: inline-block;">
                        <input type="checkbox" name="wuliaolingy"  id="wuliaolingy" data-id="1" onclick="feedeal(5)"/>&nbsp;&nbsp;
                        <label for="wuliaolingy">物料领用类</label>
                    </div>
                    <div class="form-group" style="padding: 10px;display: inline-block;">
                        <input type="checkbox" name="projinchang"  id="projinchang" data-id="1" onclick="feedeal(7)"/>&nbsp;&nbsp;
                        <label for="projinchang">产品进场类</label>
                    </div>
                    <div class="alert alert-warning alert-dismissible fade in" role="alert" id="xzfylx">

                        <td>请选择类型</td>

                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" onclick="ifInputNullGtotwo();">确认</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
        </form>
    </div>

    <!-- 全局js -->


<script src="__STATIC__/layout/js/contabs_sub.js"></script>
<script src="__STATIC__/layout/js/common.js"></script>
<script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
<!-- Sweet alert -->
<script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
 <script src="__STATIC__/layout/js/plugins/laydate/laydate.js"></script>
<script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>
<script src="__STATIC__/layout/js/plugins/suggest/bootstrap-suggest.min.js"></script>


    <!-- Web Uploader -->
    <script type="text/javascript">
        // 添加全局站点信息
        var BASE_URL = '__STATIC__/layout/js/plugins/webuploader';
    </script>
    <script src="__STATIC__/layout/js/plugins/webuploader/webuploader.min.js"></script>

<script>


function jiben() {
    $('.jiben').show()
    $('.xiangxi').hide()
    $('.huobu').hide()

}

function xiangxi() {
    $('.xiangxi').show()
    $('.jiben').hide()
    $('.huobu').hide()

}

function huobu() {
    $('.huobu').show()
    $('.xiangxi').hide()
    $('.jiben').hide()

}

 function feedeal(num){
     var aid =$('#addfreeMIngxi').attr("aid");
     var formData = $('#addInfo').serialize();
     switch(num){
         case 1:
             var id=$('#formalhbl').attr("data-id");
             var fylx=$('#fylx').val();
             if(id==1){
                 fylx--;
                 $('#fylx').val(fylx);
                 $('#formalhbl').attr("data-id",0);
                 $.ajax({
                     'type':'post',
                     'url':'{:url("TiFeiyong/getfylx")}?aid='+aid+'&num='+num,
                     'data':formData, //获取
                     'dataType':'json',
                     success: function(data) {
                         if(data.code==200){
                             if(fylx==-1){
                                 $('#xzfylx').text('');
                             }else {

                             }
                             $('#xzfylx').append(data.info);
                         }else {
                             swal('',data.message,'warning');
                         }
                     }
                 });
                 $('#suihuozhekou').attr("disabled","disabled");
                 $('#projinchang').attr("disabled","disabled");
             }else {
                 fylx++;
                 if(fylx==0){
                     $('#xzfylx').text("请选择类型");
                     $('#suihuozhekou').removeAttr("disabled");
                     $('#projinchang').removeAttr("disabled");
                     //$("#xzfylx").text(Hello <b>world</b>!);
                 }
                 $('#fylx').val(fylx);
                 $('#formalhbl').attr("data-id",1);
                 $('.for').remove();


                 console.log(fylx)
             }
             break;
         case 2:
             var id=$('#suihuozhekou').attr("data-id");
             var fylx=$('#fylx').val();
             if(id==1){
                 fylx--;
                 $('#fylx').val(fylx);
                 $('#suihuozhekou').attr("data-id",0);
                 $.ajax({
                     'type':'post',
                     'url':'{:url("TiFeiyong/getfylx")}?aid='+aid+'&num='+num,
                     'data':formData, //获取
                     'dataType':'json',
                     success: function(data) {
                         if(data.code==200){
                             $('#xzfylx').text('');
                             $('#xzfylx').append(data.info);
                         }else {
                             swal('',data.message,'warning');
                         }
                     }
                 });
                 $('#formalhbl').attr("disabled","disabled");
                 //$('#suihuozhekou').attr("disabled","disabled");
                 $('#tejiabucha').attr("disabled","disabled");

                 $('#wuliaolingy').attr("disabled","disabled");
                 $('#projinchang').attr("disabled","disabled");
             }else {
                 fylx++;
                 $('#fylx').val(fylx);
                 $('#suihuozhekou').attr("data-id",1);
                 $('.sui').remove();
                 $('#xzfylx').text("请选择类型");
                 $('#formalhbl').removeAttr("disabled");
                 //$('#suihuozhekou').removeAttr("disabled");
                 $('#tejiabucha').removeAttr("disabled");
                 $('#wuliaolingy').removeAttr("disabled");
                 $('#projinchang').removeAttr("disabled");
                 console.log(fylx)
             }
             break;
         case 4:
             var id=$('#tejiabucha').attr("data-id");
             var fylx=$('#fylx').val();
             if(id==1){
                 fylx--;
                 $('#fylx').val(fylx);
                 $('#tejiabucha').attr("data-id",0);
                 $.ajax({
                     'type':'post',
                     'url':'{:url("TiFeiyong/getfylx")}?aid='+aid+'&num='+num,
                     'data':formData, //获取
                     'dataType':'json',
                     success: function(data) {
                         if(data.code==200){
                             if(fylx==-1){
                                 $('#xzfylx').text('');
                             }
                             $('#xzfylx').append(data.info);
                         }else {
                             swal('',data.message,'warning');
                         }
                     }
                 });
                 $('#suihuozhekou').attr("disabled","disabled");
                 $('#projinchang').attr("disabled","disabled");
             }else {
                 fylx++;
                 if(fylx==0){
                     $('#xzfylx').text("请选择类型");
                     $('#suihuozhekou').removeAttr("disabled");
                     $('#projinchang').removeAttr("disabled");
                 }
                 $('#fylx').val(fylx);
                 $('#tejiabucha').attr("data-id",1);
                 $('.tej').remove();


             }
             break;
         case 5:
             var id=$('#wuliaolingy').attr("data-id");
             var fylx=$('#fylx').val();
             if(id==1){
                 fylx--;
                 $('#fylx').val(fylx);
                 $('#wuliaolingy').attr("data-id",0);
                 $.ajax({
                     'type':'post',
                     'url':'{:url("TiFeiyong/getfylx")}?aid='+aid+'&num='+num,
                     'data':formData, //获取
                     'dataType':'json',
                     success: function(data) {
                         if(data.code==200){
                             if(fylx==-1){
                                 $('#xzfylx').text('');
                             }
                             $('#xzfylx').append(data.info);
                         }else {
                             swal('',data.message,'warning');
                         }
                     }
                 });
                 /*$('#formalhbl').attr("disabled","disabled");
                 //$('#suihuozhekou').attr("disabled","disabled");
                 $('#tejiabucha').attr("disabled","disabled");
                 $('#wuliaolingy').attr("disabled","disabled");
                 $('#projinchang').attr("disabled","disabled");*/
                 $('#suihuozhekou').attr("disabled","disabled");
                 $('#projinchang').attr("disabled","disabled");
             }else {
                 fylx++;
                 if(fylx==0){
                     $('#xzfylx').text("请选择类型");
                     $('#suihuozhekou').removeAttr("disabled");
                     $('#projinchang').removeAttr("disabled");
                     //$("#xzfylx").text(Hello <b>world</b>!);
                 }
                 $('#fylx').val(fylx);
                 $('#wuliaolingy').attr("data-id",1);
                 $('.wul').remove();


                 console.log(fylx)
             }
             break;
         case 7:
             var id=$('#projinchang').attr("data-id");
             var fylx=$('#fylx').val();
             if(id==1){
                 fylx--;
                 $('#fylx').val(fylx);
                 $('#projinchang').attr("data-id",0);
                 $.ajax({
                     'type':'post',
                     'url':'{:url("TiFeiyong/getfylx")}?aid='+aid+'&num='+num,
                     'data':formData, //获取
                     'dataType':'json',
                     success: function(data) {
                         if(data.code==200){
                             $('#xzfylx').text('');
                             $('#xzfylx').append(data.info);
                         }else {
                             swal('',data.message,'warning');
                         }

                     }
                 });
                 $('#formalhbl').attr("disabled","disabled");
                 $('#suihuozhekou').attr("disabled","disabled");
                 $('#tejiabucha').attr("disabled","disabled");
                 $('#wuliaolingy').attr("disabled","disabled");
                 //$('#projinchang').attr("disabled","disabled");
             }else {
                 fylx++;
                 $('#fylx').val(fylx);
                 $('#projinchang').attr("data-id",1);
                 $('.pro').remove();
                 $('#xzfylx').text("请选择类型");
                 $('#formalhbl').removeAttr("disabled");
                 $('#suihuozhekou').removeAttr("disabled");
                 $('#tejiabucha').removeAttr("disabled");
                 $('#wuliaolingy').removeAttr("disabled");
                 //$('#projinchang').removeAttr("disabled");
                 console.log(fylx)
             }
             break;
         default:
             wrong_new_job="系统繁忙，请稍后";
             break;
     }
 }//formalhbl  for
    function ifInputNullGto() {
     console.log('aa')
       // ifInputNull('#addfreeMIngxi',function () {
            console.log('bb')
            var aid =$('#addfreeMIngxi').attr("aid");
            var formData = $('#addInfo').serialize();
            console.log('cc')
            $("#myModel1").modal('show')
            console.log('dd')
            return false
      //  });
    }

   function ifInputNullGtotwo() {  //请选择费用类型的确认
       var fylx=$('#fylx').val();
       console.log(fylx);
       if(fylx==0){
           swal('','请选择类型','warning');
       }else {
           ifInputNull('#addfreeMIngxi',function () { //
               var aid =$('#addfreeMIngxi').attr("aid");
               var formData = $('#addInfo').serialize();
               var formData2 = $('#addInfo2').serialize();
               //$("#myModel1").modal('show')


               if(aid==''||aid==0){
                   $.ajax({
                       url: "{:url('TiFeiyong/saveInfo')}",
                       type: 'post',
                       data: formData,
                       dataType: 'json',
                       success: function(data) {
                           if(data.code==200){
                               var testNoBtn = $("input[name='jxs_id']").val();
                               aid=data.value.id
                               $('#addfreeMIngxi').attr("aid",aid);
                               var index = layer.open({
                                   type: 2,
                                   title: '添加费用明细',
                                   area: ['90%', '90%'],
                                   fixed: false, //不固定
                                   maxmin: true,

                                   //content:"{:url('TiFeiyong/addListHtml')}?id="+data.value.id+'&jxsid='+testNoBtn+'&aid='+aid+'&'+formData2 //formData2 前的&为什么不起作用
                                   content:"{:url('TiFeiyong/addListHtml')}?"+formData2+'&id='+data.value.id+'&jxsid='+testNoBtn+'&aid='+aid
//                           content:"{:url('TiFeiyong/addListHtml')}?id="+data.value.id+'&jxsid='+testNoBtn
                               });
                               layer.full(index)

                           }else {
                               swal('',data.message,'warning');
                           }

                       }
                   })
               }else {
                   var testNoBtn = $("input[name='jxs_id']").val();
                   layer.open({
                       type: 2,
                       title: '添加费用明细',
                       area: ['90%', '90%'],
                       fixed: false, //不固定
                       maxmin: true,

                       content:"{:url('TiFeiyong/addListHtml')}?id="+aid+'&jxsid='+testNoBtn+'&aid='+aid+'&'+formData2

                   });
               }

               return false
           });
       }




       /*var aid =$('#addfreeMIngxi').attr("aid");
       var formData = $('#addInfo').serialize();

       console.log(aid)
       console.log(formData)
       $("#myModel1").modal('show') */ //可以选择费用类型
   //alert(1)
       //ifInputNull 判断输入框不能为空  addfreeMIngxi:父级from 的id

       /*$('.xiangxi').show()
       $('.jiben').hide()
       $('.huobu').hide()*/


       /*$('.myModel1').show()

       )*/

       /*ifInputNull('#addfreeMIngxi',function () {
           console.log('3');
           var aid =$('#addfreeMIngxi').attr("aid");
           var formData = $('#addInfo').serialize();
           console.log(formData);
           console.log('2');
           if(aid==''||aid==0){
               $.ajax({
                   url: "{:url('TiFeiyong/saveInfo')}",
                   type: 'post',
                   data: formData,
                   dataType: 'json',
                   success: function(data) {
                       if(data.code==200){
                           var testNoBtn = $("input[name='jxs_id']").val();
                           aid=data.value.id
                           $('#addfreeMIngxi').attr("aid",aid);
                           var index = layer.open({
                               type: 2,
                               title: '添加费用明细',
                               area: ['90%', '90%'],
                               fixed: false, //不固定
                               maxmin: true,
                               /!*btn:["保存","返回"],*!/
                               content:"{:url('TiFeiyong/addListHtml')}?id="+data.value.id+'&jxsid='+testNoBtn+'&aid='+aid
//                           content:"{:url('TiFeiyong/addListHtml')}?id="+data.value.id+'&jxsid='+testNoBtn
                           });
                           layer.full(index)

                       }else {
                           swal('',data.message,'warning');
                       }

                   }
               })
           }else {
               var testNoBtn = $("input[name='jxs_id']").val();
               layer.open({
                   type: 2,
                   title: '添加费用明细',
                   area: ['90%', '90%'],
                   fixed: false, //不固定
                   maxmin: true,
                   /!*btn:["保存","返回"],*!/
                   content:"{:url('TiFeiyong/addListHtml')}?id="+aid+'&jxsid='+testNoBtn+'&aid='+aid
//                           content:"{:url('TiFeiyong/addListHtml')}?id="+data.value.id+'&jxsid='+testNoBtn
               });
           }

           return false
       });*/
   }


// 文件上传
jQuery(function() {
    var $ = jQuery,
        $list = $('#thelist'),
        $btn = $('#ctlBtn'),
        state = 'pending',
        uploader;

    var ids = [{if condition="$aid neq 0"} value="{$apply.annex_id}" {/if}];
        uploader = WebUploader.create({

            // 不压缩image
            resize: false,

            // swf文件路径
            swf: BASE_URL + '/js/Uploader.swf',

            // 文件接收服务端。
            server: '{:url("upload/fileupload")}',

            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: '#picker'
        });

    // 当有文件添加进来的时候
    uploader.on( 'fileQueued', function( file ) {
        $list.append( '<div id="' + file.id + '" class="item">' +
            '<h4 class="info">' + file.name + '</h4>' +
            '<p class="state">等待上传...</p>' +
            '</div>' );
    });

    // 文件上传过程中创建进度条实时显示。
    uploader.on( 'uploadProgress', function( file, percentage ) {
        var $li = $( '#'+file.id ),
            $percent = $li.find('.progress .progress-bar');

        // 避免重复创建
        if ( !$percent.length ) {
            $percent = $('<div class="progress progress-striped active">' +
                '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                '</div>' +
                '</div>').appendTo( $li ).find('.progress-bar');
        }

        $li.find('p.state').text('上传中');

        $percent.css( 'width', percentage * 100 + '%' );
    });

    uploader.on( 'uploadSuccess', function( file,response) {
        if(response.success)
            ids.push(response.id)
        $( '#'+file.id ).find('p.state').text(response.msg);
    });

    uploader.on( 'uploadError', function( file ) {
        $( '#'+file.id ).find('p.state').text('上传出错');
    });

    uploader.on( 'uploadComplete', function( file ) {
        $('#attach').val(ids.join(','))
        $( '#'+file.id ).find('.progress').fadeOut();
    });

    uploader.on( 'all', function( type ) {
        if ( type === 'startUpload' ) {
            state = 'uploading';
        } else if ( type === 'stopUpload' ) {
            state = 'paused';
        } else if ( type === 'uploadFinished' ) {
            state = 'done';
        }

        if ( state === 'uploading' ) {
            $btn.text('暂停上传');
        } else {
            $btn.text('开始上传');
        }
    });

    $btn.on( 'click', function() {
        if ( state === 'uploading' ) {
            uploader.stop();
        } else {
            uploader.upload();
        }
        return false
    });

    $('#renyuan').on('click','.ren .close',function () {
        $(this).closest('.ren').remove()
    })
});


</script>
<script>
    function tijiao(state) {
        var num = 0;
        var aid = {$aid};
        var is_notice = 0;
        $(".ckde").each(function () {
            //console.log("555");
            num++;
        })
        var msg = "";
        if ($("#theme").val() == "") {
            msg = "主题不能为空";
        } else if ($("#remainMan").val() == "") {
            msg = "经销商必须选择";
        }
        else if (num == 0) {
            msg = "至少一条明细";
        }
        ifInputNull('#addfreeMIngxi',function () {
        if (msg == "") {
            /*if ($("input[name='is_notice']").prop("checked")) { //tpm没有归档提醒，如有则加上此处
                is_notice = 1;
            }*/
            $.post("{:url('ti_feiyong/baocunapply')}", {
                aid: aid,
                jxs: $("#remainMan").val(),
                is_notice: is_notice,
                fujian: $("#attach").val(),
                state: state,
                title: $("#actionTheme").val(),
                jinhuo_shijian_start:$("input[name='jinhuo_shijian_start']").val(),
                jinhuo_shijian_end:$("input[name='jinhuo_shijian_end']").val(),
                jinhuo_jine:$("#jinhuo_jine").val(),
                is_jinhuo:$("input[name='is_jinhuo']").val(),

            }, function (re) {
                //alert(re);
                var res = JSON.parse(re);
                if (res["state"] == 1) {
                    swal({
                        title: "完成",
                        text: "操作已成功",
                        type: "success"
                    }, function () {
                        location.href = "{:url('TiFeiyong/index')}";
                    });
                } else {
                    swal({
                        title: "错误",
                        text: res["msg"],
                        type: "warning"
                    });
                }
            })
        } else {
            swal({
                title: "错误",
                text: msg,
                type: "warning"
            });
        }
    })
    }

   $(function () {
       var aid="{$aid}";
       if(aid==0){
           //新增时经过这里
           $("#us").parents('td').siblings().find('input[type2="text"]').attr('disabled',true);
           //$(".jxs_id").val(jxsid);
       }else
       {
           //修改时经过这里，
           var jinhuoType="{$apply.is_jinhuo}";
           if(jinhuoType==1){
               $(".btn-white").eq(0).addClass("active");
               $(".btn-white").eq(1).removeClass("active");
              // $("#us").parents('td').siblings().find('input[type2="text"]').attr('disabled',false);
               $("#jinhuodeal").siblings().each(function(){
                   if($(this).hasClass('xds_addTime')){
                       $(this).find('input[type2="text"]').attr('disabled',false);
                   }else{
                       $(this).find('input[type2="text"]').attr('disabled',false);
                   }
               })

           }else {
               $("#us").parents('td').siblings().find('input[type2="text"]').attr('disabled',true);
           }


       }
   })






    function xiugai(did,ctime){
        ifInputNull('#addfreeMIngxi',function () {
            var aid =$('#addfreeMIngxi').attr("aid");
            var formData = $('#addInfo').serialize();
            var testNoBtn = $("input[name='jxs_id']").val();
            layer.open({
                type: 2,
                title: '添加费用明细',
                area: ['90%', '90%'],
                fixed: false, //不固定
                maxmin: true,
                content:"{:url('TiFeiyong/xiugai')}?id="+aid+'&jxsid='+testNoBtn+'&aid='+aid+'&did='+did+'&ctime='+ctime
//                content:"{:url('TiFeiyong/addListHtml')}?id="+aid+'&jxsid='+testNoBtn+'&aid='+aid
            });
            return false
        });
        /*var index = layer.open({
            type:2,
            title:'修改数据',
            area:['100%','100%'],
            maxmin:true,
            content:'{:url("xiugai")}?did='+did
        })*/
    }
    function shanchu(did,ctime){
        console.log(did);
        console.log('ddd');
        var num=0;
        $(".ckde").each(function(){
            num++;
        })

        $.post("{:url('shanchu')}",{did:did,ctime:ctime,aid:$("#addData").attr("aid")},function(re){
            if(re==1){
                swal({
                    title: "成功",
                    text:  "操作已完成",
                    type: "success"
                },function(){
                    location.href="{:url('TiFeiyong/addinfohtml')}?aid="+did;
                });
            }else{
                swal({
                    title: "错误",
                    text:  "您没有选择要删除的明细",
                    type: "warning"
                });
            }
        })

    }

    //返回
    $('#toback').click(function () {
        window.location="{:url('TiFeiyong/index')}";
    })




</script>
    {if condition="$apply['is_jinhuo'] eq 1"}
    <script>
       /* $(".xds_addTime").find('input[name=jinhuo_shijian_start]').val("$apply['jinhuo_shijian_start']")
        $(".xds_addTime").find('input[name=jinhuo_shijian_end]').val("$apply['jinhuo_shijian_end']")
        var start = {$apply['jinhuo_shijian_start']};
        var end = {$apply['jinhuo_shijian_end']};
        console.log(start);
        console.log('eee22eee');
        console.log(end);
        $(document).find('input[name=jinhuo_shijian_start]').val(start)
        $(document).find('input[name=jinhuo_shijian_end]').val(end)
        console.log('666');
        $(document).find('input[name=jinhuo_jine]').val(end)*/


        /*$(document).find('[name=jinhuo_shijian_start]').val('2018-11-10')
       $(document).find('[name=jinhuo_shijian_end]').val('2018-11-15')*/
       $('[name=jinhuo_jine]').val("{$apply['jinhuo_jine']}")
       var jinhuo_jine ="{$apply['jinhuo_jine']}";
       if(jinhuo_jine>0){
           var hanshuis = "{$all['hanshuis']}";
           var yjjhfb =parseFloat(100*hanshuis/jinhuo_jine);
           $('#yjjhfb').val(yjjhfb);
       }
       /*console.log(jinhuo_jine)
       console.log('jinhuo_jine')*/


        //$(document).find('input[name=jinhuo_shijian_start]').val("$apply['jinhuo_shijian_start']")
        //$(document).find('input[name=jinhuo_shijian_end]').val("$apply['jinhuo_shijian_end']")
        /*$(function () {
            entranceX('jxs_id',
                "{:url('select/myjxsjson')}",
                '{:url("BiHaiChaoSheng/selectList?str=jxs_id&url=myzonetreeajax")}',
                '经销商不能为空', '');
        });*/
    </script>
    {/if}
    <script>
        $(document).ready(function(){
            var is_jinhuo ={$apply['is_jinhuo']};
            if(is_jinhuo==1){

                var value = '2018';
                $('#xds_addTime0').text(value);
                console.log('a21b');
            }
        })

    </script>
</body>

</html>